<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c"%>
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>员工管理</title>
<!-- Tell the browser to be responsive to screen width -->
<meta
	content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
	name="viewport">
<!-- Bootstrap 3.3.6 -->
<link rel="stylesheet" href="${pageContext.request.contextPath}/bootstrap/css/bootstrap.min.css">
<!-- Font Awesome -->
<link rel="stylesheet"
	href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css">
<!-- Ionicons -->
<link rel="stylesheet"
	href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="${pageContext.request.contextPath}/dist/css/AdminLTE.min.css">
<!-- AdminLTE Skins. Choose a skin from the css/skins
       folder instead of downloading all of them to reduce the load. -->
<link rel="stylesheet" href="${pageContext.request.contextPath}/dist/css/skins/_all-skins.min.css">
<!-- iCheck -->
<link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/iCheck/flat/blue.css">
<!-- Morris chart -->
<link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/morris/morris.css">
<!-- jvectormap -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/plugins/jvectormap/jquery-jvectormap-1.2.2.css">
<!-- Date Picker -->
<link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/datepicker/datepicker3.css">
<!-- Daterange picker -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/plugins/daterangepicker/daterangepicker-bs3.css">
<!-- bootstrap wysihtml5 - text editor -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
<link rel="stylesheet" href="${pageContext.request.contextPath}/dist/css/theme.css" media="all">
<script type="text/javascript" src="plugins/jQuery/jQuery-2.2.0.min.js"></script>

</head>

<body class="hold-transition skin-blue sidebar-mini"
	style="font-family:Microsoft YaHei;">
	<div class="wrapper">
 <div id="resultDiv"></div>
		<header class="main-header"> <!-- Logo -->
		<div class="logo" style="background-color:#ec7500;">
			<!-- logo for regular state and mobile devices -->
			<span class="logo-lg"><b
				style="font-size:18px;margin-left:-40px ">厂车管理系统</b> </span>
		</div>
		<!-- Header Navbar: style can be found in header.less --> <nav
			class="navbar navbar-static-top" style="background-color:#ec7500;">
		<!-- Sidebar toggle button--> <a href="#" class="sidebar-toggle"
			data-toggle="offcanvas" role="button"> <span class="sr-only">Toggle
				navigation</span> </a>

		<div class="navbar-custom-menu">
			<ul class="nav navbar-nav">
				<!-- User Account:-->
				<li class="dropdown user user-menu"><span class="hidden-xs"></span>
				</li>
				<li style="color:#ffffff; background:#959595;padding:15px">${sessionScope.CurrentUser.username}</li>
				<li><a><i class="fa fa-sign-out"></i> </a></li>
			</ul>
		</div>
		</nav> </header>
		<!-- Left side column. contains the logo and sidebar -->
		<aside class="main-sidebar"> <!-- sidebar: style can be found in sidebar.less -->
		<section class="sidebar"> <!-- sidebar menu: : style can be found in sidebar.less -->
	<ul class="sidebar-menu">
		<c:forEach var = "UserRoleActionsId"  items = "${sessionScope.CurrentUserActionsId}">
		  <c:choose>
		    <c:when test ="${UserRoleActionsId == 4 }">
			<li class="active treeview"><a href="${pageContext.request.contextPath}/showEmps.do"> <i
					class="fa fa-user"></i><span>员工管理</span>
					 </a></li>
					 </c:when>
					 <c:when test ="${UserRoleActionsId == 8 }">
			<li class="treeview"><a href="${pageContext.request.contextPath}/showBuses.do"> <i class="fa fa-bus"></i>
					<span>车辆管理</span> </a></li>
					</c:when>
					<c:when test ="${UserRoleActionsId == 12 }">
			<li class="treeview"><a href="${pageContext.request.contextPath}/carschedule_all.do"> <i class="fa fa-calendar"></i>
					<span>排班管理</span> </a></li>
					</c:when>
					<c:when test ="${UserRoleActionsId == 16 }">
			<li class="treeview"><a href="${pageContext.request.contextPath}/pages/stationManage.jsp"> <i
					class="fa fa-map-marker"></i> <span>站点管理</span> </a></li>
					</c:when>
					<c:when test ="${UserRoleActionsId == 20 }">
			<li class="treeview"><a href="${pageContext.request.contextPath}/pages/lineManage.jsp"> <i class="fa fa-road"></i>
					<span>线路管理</span> </a></li>
					</c:when>
					<c:when test ="${UserRoleActionsId == 24 }">
			<li class="treeview"><a href="${pageContext.request.contextPath}/findUserFirstPage.do"> <i class="fa fa-user-plus"></i>
					<span>用户管理</span> </a></li>
					</c:when>
					<c:when test ="${UserRoleActionsId == 28 }">
			<li class="treeview"><a href="${pageContext.request.contextPath}/findRoleFirstPage.do"> <i
					class="fa fa-check-square-o"></i> <span>角色管理</span> </a></li>
					</c:when>
					<c:when test ="${UserRoleActionsId == 32 }">
			<li class="treeview"><a href="${pageContext.request.contextPath}/pages/dataSave.jsp"> <i class="fa fa-save"></i>
					<span>数据备份</span> </a></li>
					</c:when>
					</c:choose></c:forEach>
		</ul>
		</section> <!-- /.sidebar --> </aside>

		<!-- Content Wrapper. Contains page content -->
		<div class="content-wrapper" style="background-color:#f2f2f2;">
			<!-- Main content -->
			<section class="content">

			<form class="navbar-form navbar-left" role="search"  action="${pageContext.request.contextPath}/groupSearch.do" method="post">
				<div class="form-group">
					<input type="text" class="form-control" id="navbar-search-input"
						placeholder="输入姓名" name="searchName"
						style="width:110px; margin-left:-5px;color:#ffffff;"> <input
						type="text" class="form-control" id="navbar-search-input"  name="searchEmpId"
						placeholder="输入工号" style="width:185px;margin-left:-2px;">
					<select name="searchDept" class="form-control" 
						style="width:127px;margin-left:-2px;" >
						<option value="部门1"  value="部门">部门</option>
						<c:forEach var="k" items="${depts}">
						<option value="${k}">${k}</option>
						</c:forEach>
					</select> <select name="searchClasses" class="form-control" 
						style="width:110px;margin-left:-2px;">
						<option value="">班次</option>
						<c:forEach var="o" items="${classes}">
						<option value="${o}">${o}</option>
						</c:forEach>
					</select> <select name="searchStation" class="form-control"
						style="width:110px;margin-left:-2px;">
						<option value="">站点</option>
						<c:forEach var="st" items="${stations}">
						<option value="${st}">${st}</option>
						</c:forEach>
					</select>
				</div>
				<button class="btn btn-info"  type="submit"	style="background:none;border:none;">
					<i class="fa   fa-search" style="color:#ff9900;"></i>
				</button>
				<a style="padding:0px 15px;margin-top:10px;cursor:pointer;"
					data-toggle="modal" data-target="#myModal"> <i
					class="fa  fa-plus-square" style="color:#ff9900;"></i>&nbsp;增加员工 </a>
			</form>
			<div class="box">
				<!-- /.box-header -->
				<div class="box-body"
					style="padding-top:2px;margin:margin-top:-4px;">
					<table class="table table-bordered table-striped">
						<tr>
							<th style="width:55px;text-align:center;">姓名</th>
							<th style="width:40px;text-align:center;">工号</th>
							<th style="width:55px;text-align:center;">部门</th>
							<th style="width:55px;text-align:center;">班次</th>
							<th style="width:55px;text-align:center;">站点</th>
							<th style="width:55px;text-align:center;">操作</th>
						</tr>
						<c:forEach  var="items" items="${emps}">
			         <TR>
			             <TD height="30">${items.name}</TD>
			            <TD height="30">${items.employee_id}</TD>
			            <TD height="30">${items.department}</TD>
			            <TD height="30">${items.runs_id}</TD>
			            <TD height="30">${items.stationname}</TD>
			           <td style="text-align:center;">
			           <c:forEach var = "actionId" items = "${sessionScope.CurrentUserActionsId}">
								    <c:if test="${actionId == 3 }"> 
			           <a onclick="checkAndUpdate(${items.employee_id})" data-toggle="modal" data-target="#modify" > <i class="fa  fa-edit" 
										style="color:#ff9900;margin:0px 15px 0 -10px;"></i> </a> 
										</c:if>
											    <c:if test="${actionId == 2 }"> 
										<a href="deleteEmp.do?Id=${items.id}"> <i
										class="fa  fa-trash" style="color:#ff9900"></i>&nbsp;&nbsp;</a>
										</c:if></c:forEach>
										</td>
										
							
			         </TR>
			     </c:forEach>
						</table>
						
					</div>
					<!-- /.box-body -->
					<div class="box-footer clearfix">
						<ul class="pagination pagination-sm no-margin pull-right">
							<li><a href="changePages.do?currentPage=${sessionScope.pc.previousPage}">&laquo;</a></li>
							<c:forEach var="s" begin="1" end="${sessionScope.pc.totalPages}">
							<li><a href="changePages.do?currentPage=${s}">${s}</a></li>
			                  </c:forEach>
							<li><a href="changePages.do?currentPage=${sessionScope.pc.nextPage}">&raquo;</a></li>
						</ul>
					</div>
				</div>
				
				<!-- 模态框（Modal） -->
				<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
					aria-labelledby="myModalLabel" aria-hidden="true">
					<div class="modal-dialog">
						<div class="modal-content"
							style="width:400px;height:470px;position:relative; top:50px;left:100px;">
							<div class="modal-header"
								style="color:#ffffff;background:#ff9900;">
								<button type="button" class="close" data-dismiss="modal"
									aria-hidden="true">
									<i class="fa  fa-close " style="color:#ffffff"></i>
								</button>
								<h4 class="modal-title" id="myModalLabel">添加员工</h4>
							</div>
							<div class="modal-body">
								<form class="form-horizontal" role="form" action="${pageContext.request.contextPath}/saveEmp.do" method="post">
									<div class="form-group" style="margin-left:30px;">
										<label for="lastname" class="col-sm-2 control-label">姓名</label>
										<div class="col-sm-8">
											<input type="text" class="form-control" id="lastname" name="empName"
												style="background:none;border:1px solid #bcbcbc;color: black" placeholder="请输入姓">
										</div>
									</div>
									<div class="form-group" style="margin-left:30px;">
										<label for="lastname" class="col-sm-2 control-label">工号</label>
										<div class="col-sm-8">
											<input type="text" class="form-control" id="lastname" name="empID"
												style="background:none;border:1px solid #bcbcbc;color: black" placeholder="请输入姓">
										</div>
									</div>
									<div class="form-group" style="margin-left:30px;">
										<label for="firstname" class="col-sm-2 control-label">部门</label>
										<div class="col-sm-8">
											<input type="text" class="form-control" id="firstname" name="empDept"
												style="background:none;border:1px solid #bcbcbc;color: black" placeholder="请输入名字">
										</div>
									</div>
									<div class="form-group" style="margin-left:30px;">
										<label for="firstname" class="col-sm-2 control-label">组别</label>
										<div class="col-sm-8">
											<input type="text" class="form-control" id="firstname"  name="empGroup"
												style="background:none;border:1px solid #bcbcbc;color: black" placeholder="请输入名字">
										</div>
									</div>
									<div class="form-group" style="margin-left:30px;">
										<label for="firstname" class="col-sm-2 control-label">站点</label>
										<div class="col-sm-8">
											<input type="text" class="form-control" id="firstname" name="empPoint"
												style="background:none;border:1px solid #bcbcbc;color: black" placeholder="请输入名字">
										</div>
									</div>
									<div class="form-group" style="margin-left:30px;">
										<label for="firstname" class="col-sm-2 control-label">班次</label>
										<div class="col-sm-8">
											<input type="text" class="form-control" id="firstname" name="empClasses"
												style="background:none;border:1px solid #bcbcbc;color: black"
												placeholder="请输入名字">
										</div>
									</div>
									<div class="modal-footer" style="padding:0 30%;">
								<button type="submit" class="btn btn-default"
									style="color:#ffffff;background:#ff9900;"  >保&nbsp;存</button>
								<button type="button" class="btn btn-default"
									data-dismiss="modal" style="color:#ffffff;background:#a0a0a0;">取&nbsp;消
								</button>
							</div>
								</form>
							</div>
							
						</div>
						<!-- /.modal-content -->
					</div>
					<!-- /.modal -->
				</div>
				
				<!-- 手动修改数据 -->
					<div class="modal fade" id="modify" tabindex="-1" role="dialog"
					aria-labelledby="myModalLabel" aria-hidden="true">
					<div class="modal-dialog">
						<div class="modal-content"
							style="width:400px;height:470px;position:relative; top:50px;left:100px;">
							<div class="modal-header"
								style="color:#ffffff;background:#ff9900;">
								<button type="button" class="close" data-dismiss="modal"
									aria-hidden="true">
									<i class="fa  fa-close " style="color:#ffffff"></i>
								</button>
								<h4 class="modal-title" id="myModalLabel">修改员工信息</h4>
							</div>
							<div class="modal-body">
								<form class="form-horizontal" role="form" action="${pageContext.request.contextPath}/modiEmp.do" method="post">
									<input type="hidden" class="form-control" id="Id" name="modiID"
												style="background:none;border:1px solid #bcbcbc;color: black;display: none" placeholder="请输入姓" >
									<div class="form-group" style="margin-left:30px;">
										<label for="lastname" class="col-sm-2 control-label">姓名</label>
										<div class="col-sm-8">
											<input type="text" class="form-control" id="EmpName" name="modiName"
												style="background:none;border:1px solid #bcbcbc;color: black" placeholder="请输入姓" >
										</div>
									</div>
									<div class="form-group" style="margin-left:30px;">
										<label for="lastname" class="col-sm-2 control-label">工号</label>
										<div class="col-sm-8">
											<input type="text" class="form-control" id="EmpId" name="modiEmpId"
												style="background:none;border:1px solid #bcbcbc;color: black" placeholder="请输入姓" value="">
										</div>
									</div>
									<div class="form-group" style="margin-left:30px;">
										<label for="firstname" class="col-sm-2 control-label">部门</label>
										<div class="col-sm-8">
											<input type="text" class="form-control" id="EmpDept" name="modiDept"
												style="background:none;border:1px solid #bcbcbc;color: black" placeholder="请输入名字"  value="">
										</div>
									</div>
									<div class="form-group" style="margin-left:30px;">
										<label for="firstname" class="col-sm-2 control-label">组别</label>
										<div class="col-sm-8">
											<input type="text" class="form-control" id="EmpGroup"  name="modiGroup"
												style="background:none;border:1px solid #bcbcbc;color: black" placeholder="请输入名字" value="">
										</div>
									</div>
									<div class="form-group" style="margin-left:30px;">
										<label for="firstname" class="col-sm-2 control-label">站点</label>
										<div class="col-sm-8">
											<input type="text" class="form-control" id="EmpStationName" name="modiStation"
												style="background:none;border:1px solid #bcbcbc;color: black" placeholder="请输入名字" value="">
										</div>
									</div>
									<div class="form-group" style="margin-left:30px;">
										<label for="firstname" class="col-sm-2 control-label">班次</label>
										<div class="col-sm-8">
											<input type="text" class="form-control" id="EmpRunsId" name="modiClass"
												style="background:none;border:1px solid #bcbcbc;color: black"
												placeholder="请输入名字" value="">
										</div>
									</div>
									<div class="modal-footer" style="padding:0 30%;">
								<button type="submit" class="btn btn-default"
									style="color:#ffffff;background:#ff9900;"  >保&nbsp;存</button>
								<button type="button" class="btn btn-default"
									data-dismiss="modal" style="color:#ffffff;background:#a0a0a0;">取&nbsp;消
								</button>
							</div>
								</form>
							</div>
							
						</div>
						<!-- /.modal-content -->
					</div>
					<!-- /.modal -->
				</div>
			</section>
			<!-- /.content -->
		</div>
		<!-- /.content-wrapper -->

		<!-- ./wrapper -->

		<!-- jQuery 2.2.0 -->
		<script src="${pageContext.request.contextPath}/plugins/jQuery/jQuery-2.2.0.min.js"></script>
		<!-- jQuery UI 1.11.4 -->
		<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
		<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
		<script>
			$.widget.bridge('uibutton', $.ui.button);
		</script>
		<!-- Bootstrap 3.3.6 -->
		<script src="${pageContext.request.contextPath}/bootstrap/js/bootstrap.min.js"></script>
		<!-- Morris.js charts -->
		<script
			src="https://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
		<script src="${pageContext.request.contextPath}/plugins/morris/morris.min.js"></script>
		<!-- Sparkline -->
		<script src="${pageContext.request.contextPath}/plugins/sparkline/jquery.sparkline.min.js"></script>
		<!-- jvectormap -->
		<script src="${pageContext.request.contextPath}/plugins/jvectormap/jquery-jvectormap-1.2.2.min.js"></script>
		<script src="${pageContext.request.contextPath}/plugins/jvectormap/jquery-jvectormap-world-mill-en.js"></script>
		<!-- jQuery Knob Chart -->
		<script src="${pageContext.request.contextPath}/plugins/knob/jquery.knob.js"></script>
		<!-- daterangepicker -->
		<script
			src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.11.2/moment.min.js"></script>
		<script src="${pageContext.request.contextPath}/plugins/daterangepicker/daterangepicker.js"></script>
		<!-- datepicker -->
		<script src="${pageContext.request.contextPath}/plugins/datepicker/bootstrap-datepicker.js"></script>
		<!-- Bootstrap WYSIHTML5 -->
		<script
			src="${pageContext.request.contextPath}/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
		<!-- Slimscroll -->
		<script src="${pageContext.request.contextPath}/plugins/slimScroll/jquery.slimscroll.min.js"></script>
		<!-- FastClick -->
		<script src="${pageContext.request.contextPath}/plugins/fastclick/fastclick.js"></script>
		<!-- AdminLTE App -->
		<script src="${pageContext.request.contextPath}/dist/js/app.min.js"></script>
		<!-- AdminLTE dashboard demo (This is only for demo purposes) -->
		<script src="${pageContext.request.contextPath}/dist/js/pages/dashboard.js"></script>
		<!-- AdminLTE for demo purposes -->
		<script src="${pageContext.request.contextPath}/dist/js/demo.js"></script>
		<script src="${pageContext.request.contextPath}/dist/js/jquery.min.js"></script>
		
</body>
</html>
<script type="text/javascript">
	function checkAndUpdate(employeeId){
		var ajax_data = "modifyEmpId="+employeeId;
		var ajax_url = "${pageContext.request.contextPath}/showModifyData.do";
		var ajax_type = "post";
		$.ajax({
			type : ajax_type,
			url : ajax_url,
			data : ajax_data,
			success : function(msg,status){
				if(status == "success"){
					$("#Id").val(msg.id);
					$("#EmpName").val(msg.name);
					$("#EmpId").val(msg.employee_id);
					$("#EmpDept").val(msg.department);
					
					$("#EmpGroup").val(msg.group_id);
					$("#EmpStationName").val(msg.stationname);
					$("#EmpRunsId").val(msg.runs_id);
					
				}
			} 
		});
	
	}
</script>
